package com.water.camera.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.water.camera.adapter.MarkPagerAdapter;
import com.water.camera.databinding.FragmentMarksBinding;
import com.water.camera.it.WaterMarkChangeListener;
import com.water.camera.view.CustomTabProvider;

public class MarksFragment extends BaseFragment implements WaterMarkChangeListener {

    FragmentMarksBinding binding;
    WaterMarkChangeListener listener;

    public MarksFragment setWaterMarkChangeListener(WaterMarkChangeListener listener) {
        this.listener = listener;
        return this;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = FragmentMarksBinding.inflate(inflater, container, false);
        binding.tab.setCustomTabView(new CustomTabProvider(getActivity()));
        binding.pager.setAdapter(new MarkPagerAdapter(getChildFragmentManager(), this));
        binding.tab.setViewPager(binding.pager);

        return binding.getRoot();
    }

    @Override
    public void onWaterMarkChange(String name) {
        listener.onWaterMarkChange(name);
    }
}
